<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>新增员工</title>
    <meta name="description" content="这是一个 index 页面">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="icon" type="image/png" href="__PUBLIC__/assets/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="__PUBLIC__/assets/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI" />
    <link rel="stylesheet" href="__PUBLIC__/assets/css/amazeui.min.css" />
    <link rel="stylesheet" href="__PUBLIC__/assets/css/admin.css">
    <link rel="stylesheet" href="__PUBLIC__/assets/css/app.css">
</head>

<body data-type="generalComponents">


    <header class="am-topbar am-topbar-inverse admin-header">
        <div class="am-topbar-brand">
            <a href="javascript:;" class="tpl-logo">
                <img src="__IMG__/logo.png" alt="">
            </a>
        </div>
        <div class="am-icon-list tpl-header-nav-hover-ico am-fl am-margin-right">

        </div>

        <button class="am-topbar-btn am-topbar-toggle am-btn am-btn-sm am-btn-success am-show-sm-only" data-am-collapse="{target: '#topbar-collapse'}"><span class="am-sr-only">导航切换</span> <span class="am-icon-bars"></span></button>

        <div class="am-collapse am-topbar-collapse" id="topbar-collapse">

            <ul class="am-nav am-nav-pills am-topbar-nav am-topbar-right admin-header-list tpl-header-list">



                <li class="am-hide-sm-only"><a href="javascript:;" id="admin-fullscreen" class="tpl-header-list-link"><span class="am-icon-arrows-alt"></span> <span class="admin-fullText">开启全屏</span></a></li>

                <li class="am-dropdown" data-am-dropdown data-am-dropdown-toggle>
                    <a class="am-dropdown-toggle tpl-header-list-link" href="javascript:;">
                        <span class="tpl-header-list-user-nick">{$Think.session.name}</span><span class="tpl-header-list-user-ico"> <img src="__PUBLIC__/assets/img/user01.png"></span>
                    </a>
                    <ul class="am-dropdown-content">
                        <li><a href="#"><span class="am-icon-bell-o"></span> 资料</a></li>
                        <li><a href="#"><span class="am-icon-cog"></span> 设置</a></li>
                        <li><a href="/?/account/logout/"><span class="am-icon-power-off"></span> 退出</a></li>
                    </ul>
                </li>
                <li><a href="/logout" class="tpl-header-list-link"><span class="am-icon-sign-out tpl-header-list-ico-out-size"></span></a></li>
            </ul>
        </div>
    </header>






    <div class="tpl-page-container tpl-page-header-fixed">


        <div class="tpl-left-nav tpl-left-nav-hover">
            <div class="tpl-left-nav-title">

            </div>
            <div class="tpl-left-nav-list">
                <ul class="tpl-left-nav-menu">
                    <li class="tpl-left-nav-item">
                        <a href="/org_admin"  class="nav-link" >
                            <i class="am-icon-home"></i>
                            <span>首页</span>
                        </a>
                    </li>


                    <li class="tpl-left-nav-item">
                        <a href="javascript:;" class="nav-link tpl-left-nav-link-list">
                            <i class="am-icon-table"></i>
                            <span>数据列表</span>
                            <i class="am-icon-angle-right tpl-left-nav-more-ico am-fr am-margin-right"></i>
                        </a>
                        <ul class="tpl-left-nav-sub-menu" style="display: block;">
                            <li>
                                <a href="/dept_list" >
                                    <i class="am-icon-angle-right"></i>
                                    <span>部门列表</span>
                                    <i class="am-icon-star tpl-left-nav-content-ico am-fr am-margin-right"></i>
                                </a>
                                <a href='/member_list'>
                                    <i class="am-icon-angle-right"></i>
                                    <span>员工列表</span>
                                    <i class="am-icon-star tpl-left-nav-content-ico am-fr am-margin-right"></i>
                                </a>

                                <a href="/join_member_list" class="nav-link active">
                                    <i class="am-icon-angle-right"></i>
                                    <span>未激活员工列表</span>
                                    <i class="am-icon-star tpl-left-nav-content-ico am-fr am-margin-right"></i>
                                </a>

                                <a href="/meet_list">
                                    <i class="am-icon-angle-right"></i>
                                    <span>会议列表</span>
                                    <i class="am-icon-star tpl-left-nav-content-ico am-fr am-margin-right"></i>
                                </a>

                            </li>
                        </ul>
                    </li>


                    <li class="tpl-left-nav-item">
                        <a href="javascript:;" class="nav-link tpl-left-nav-link-list">
                            <i class="am-icon-wpforms"></i>
                            <span>设置</span>
                            <i class="am-icon-angle-right tpl-left-nav-more-ico am-fr am-margin-right tpl-left-nav-more-ico-rotate"></i>
                        </a>
                        <ul class="tpl-left-nav-sub-menu" style="display: block;">
                            <li>
                                <a href="/info">
                                    <i class="am-icon-angle-right"></i>
                                    <span>公司资料</span>
                                    <i class="am-icon-star tpl-left-nav-content-ico am-fr am-margin-right"></i>
                                </a>
                                <a href="/push" >
                                    <i class="am-icon-angle-right"></i>
                                    <span>消息推送</span>
                                    <i class="am-icon-star tpl-left-nav-content-ico am-fr am-margin-right"></i>
                                </a>


                            </li>
                        </ul>
                    </li>

                </ul>
            </div>
        </div>

        {if condition="($add != '1')"}

        <input type="hidden" id="user_id" value="{$user.id}" />
        {else /}

        {/if}

        <div class="tpl-content-wrapper">
            <div class="tpl-content-page-title">
            </div>
            <ol class="am-breadcrumb">
                <li><a href="#" class="am-icon-home">首页</a></li>
                <li><a href="#">未激活员工列表</a></li>
                <li class="am-active">新增员工</li>
            </ol>
            <div class="tpl-portlet-components">
                <div class="portlet-title">
                    <div class="caption font-green bold">
                        <span class="am-icon-code"></span>
                    </div>
                    <div class="tpl-portlet-input tpl-fz-ml">
                        <div class="portlet-input input-small input-inline">
                            <div class="input-icon right">
                                <i class="am-icon-search"></i>
                        </div>
                    </div>


                </div>
                <div class="tpl-block ">

                    <div class="am-g tpl-amazeui-form">


                        <div class="am-u-sm-12 am-u-md-9">
                            <form class="am-form am-form-horizontal">
                                <div class="am-form-group">
                                    <label for="name" class="am-u-sm-3 am-form-label">姓名</label>
                                    <div class="am-u-sm-9">

                                        {if condition="($add == 0)"}

                                        <input type="text" id="name" value="{$user.name}" >
                                        {else /}
                                        <input type="text" id="name" placeholder="姓名" >

                                        {/if}

                                    </div>
                                </div>

                                <div class="am-form-group">
                                    <label for="name" class="am-u-sm-3 am-form-label">邮箱</label>
                                    <div class="am-u-sm-9">
                                        {if condition="($add == 0)"}

                                        <input type="text" id="email" value="{$user.email}" >
                                        {else /}
                                        <input type="text" id="email" placeholder="邮箱" >

                                        {/if}

                                    </div>
                                </div>

                                <div class="am-form-group">
                                    <label for="name" class="am-u-sm-3 am-form-label">手机</label>
                                    <div class="am-u-sm-9">

                                        {if condition="($add == 0)"}

                                        <input type="text" id="phone" value="{$user.phone}" >
                                        {else /}
                                        <input type="text" id="phone" placeholder="手机" >

                                        {/if}
                                    </div>
                                </div>

                                <div class="am-form-group">
                                    <label for="name" class="am-u-sm-3 am-form-label">部门</label>
                                    <div class="am-u-sm-9">

                                        {if condition="($add == 0)"}

                                        <select id="dept">
                                            {volist name='list' id='d'}

                                                <option    {if condition="($user.dept_name == $d.name )"} selected="selected" {/if} value="{$d.name}">{$d.name}</option>
                                            {/volist}

                                        </select>


                                        {else /}

                                           <select id="dept">
                                               {volist name='list' id='dept'}

                                               <option value="{$dept.name}">{$dept.name}</option>
                                               {/volist}

                                           </select>
                                        {/if}
                                    </div>
                                </div>

                                <div class="am-form-group">
                                    <div class="am-u-sm-9 am-u-sm-push-3">
                                        <button type="button" id="add_btn" class="am-btn am-btn-primary">保存修改</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>

            </div>










        </div>

    </div>


    <script src="__PUBLIC__/assets/js/jquery.min.js"></script>
    <script src="__PUBLIC__/assets/js/amazeui.min.js"></script>
    <script src="__PUBLIC__/assets/js/app.js"></script>
</body>

</html>
<script type="application/javascript">

    $(function(){
       $('#add_btn').click(function(){
           var name = $('#name').val();
           var email = $('#email').val();
           var phone = $('#phone').val();
           var dept= $('#dept').val();
           if(name == ""){
               alert("请输入名字");
               return false;
           }
           if(!isEmail(email)){
               alert("请输入正确");
               return false;
           }
           if(phone == "" || phone.length != 11){
               alert("请输入正确手机");
               return false;
           }
           if(dept == ""){
               alert("请输入部门名字");
               return false;
           }

           var user_id = $('#user_id').val();
           if(typeof(user_id)=="undefined"){
               user_id = -1;
           }
           $.post('/ajax_add_join_member',{"uid":user_id,"name":name,"email":email,"phone":phone,"dept":dept},function (result) {
               window.location.href="/join_member_list";
           },'json');
       });
    });

    function isEmail(str){
        var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
        return reg.test(str);
    }
</script>